package com.pearadmin.shop.service.impl;

import java.util.List;
import java.util.ArrayList;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pearadmin.common.web.domain.request.PageDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pearadmin.shop.mapper.ShopGoodsMapper;
import com.pearadmin.shop.domain.ShopGoods;
import com.pearadmin.shop.service.IShopGoodsService;

/**
 * 店铺商品Service业务层处理
 * 
 * @author jmys
 * @date 2021-05-06
 */
@Service
public class ShopGoodsServiceImpl implements IShopGoodsService 
{
    @Autowired
    private ShopGoodsMapper shopGoodsMapper;

    /**
     * 查询店铺商品
     * 
     * @param id 店铺商品ID
     * @return 店铺商品
     */
    @Override
    public ShopGoods selectShopGoodsById(Long id)
    {
        return shopGoodsMapper.selectShopGoodsById(id);
    }

    /**
     * 查询店铺商品列表
     * 
     * @param shopGoods 店铺商品
     * @return 店铺商品
     */
    @Override
    public List<ShopGoods> selectShopGoodsList(ShopGoods shopGoods)
    {
        return shopGoodsMapper.selectShopGoodsList(shopGoods);
    }

    @Override
    public List<ShopGoods> selectShopGoodsAll() {
        return shopGoodsMapper.selectShopGoodsAll();
    }

    /**
     * 查询店铺商品
     * @param shopGoods 店铺商品
     * @param pageDomain
     * @return 店铺商品 分页集合
     * */
    @Override
    public PageInfo<ShopGoods> selectShopGoodsPage(ShopGoods shopGoods, PageDomain pageDomain)
    {
        PageHelper.startPage(pageDomain.getPage(),pageDomain.getLimit());
        List<ShopGoods> data = shopGoodsMapper.selectShopGoodsList(shopGoods);
        return new PageInfo<>(data);
    }

    /**
     * 新增店铺商品
     * 
     * @param shopGoods 店铺商品
     * @return 结果
     */

    @Override
    public int insertShopGoods(ShopGoods shopGoods)
    {
        return shopGoodsMapper.insertShopGoods(shopGoods);
    }

    /**
     * 修改店铺商品
     * 
     * @param shopGoods 店铺商品
     * @return 结果
     */
    @Override
    public int updateShopGoods(ShopGoods shopGoods)
    {
        return shopGoodsMapper.updateShopGoods(shopGoods);
    }

    /**
     * 删除店铺商品对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteShopGoodsByIds(String[] ids)
    {
        return shopGoodsMapper.deleteShopGoodsByIds(ids);
    }

    /**
     * 删除店铺商品信息
     * 
     * @param id 店铺商品ID
     * @return 结果
     */
    @Override
    public int deleteShopGoodsById(Long id)
    {
        return shopGoodsMapper.deleteShopGoodsById(id);
    }
}
